<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"  
                xmlns:h="http://java.sun.com/jsf/html"  
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:c="http://java.sun.com/jsp/jstl/core"
                xmlns:p="http://primefaces.org/ui"
                template="./default_template.xhtml"> 
    
    <ui:define name="content">
        <f:view>
            <h:form rendered="#{userController.utilisateur.typeUser == 'Admin'}">
                <h1><h:outputText value="Opérations"/></h1>
                <p:dataTable value="#{userController.allOperation}" var="item" rowStyleClass="#{item.montant lt 0 ? 'alert alert-error' : 'alert alert-success'}">
                    <p:column headerText="Date">
                         <h:outputText value="#{item.dateOperation}">
                            <f:convertDateTime pattern="MM/dd/yyyy" />
                        </h:outputText>
                    </p:column>  

                    <p:column headerText="Description"> 
                        <h:outputText value="#{item.description}"/> 
                    </p:column>  

                    <p:column headerText="Montant">
                        <h:outputText value="#{item.montant}"/>
                    </p:column>
                </p:dataTable>
            </h:form>
            <h:form rendered="#{userController.utilisateur.typeUser == 'Client'}">
                <h1><h:outputText value="Opérations"/></h1>
                <p:dataTable value="#{userController.utilisateur.comptes}" var="item">
                    <p:subTable value="#{item.operations}" var="o">
                        <f:facet name="header">  
                            #{item.type.libelleType}   
                        </f:facet> 
                        <p:column>
                            <h:outputText value="#{o.dateOperation}">
                                <f:convertDateTime pattern="MM/dd/yyyy" />
                            </h:outputText>
                        </p:column>  

                        <p:column> 
                            #{o.description}
                        </p:column>  

                        <p:column>
                            #{o.montant}
                        </p:column>
                    </p:subTable>
                </p:dataTable>
            </h:form>
        </f:view>

    </ui:define>

</ui:composition>
